//
//  main.m
//  5-19学习
//
//  Created by 钟纪旺 on 16/5/19.
//  Copyright © 2016年 zjw. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSString *Da1 = @"http://127.0.0.1:3000/";
        NSString *Da =@"http://www.baidu.com/s";
        
//        NSDictionary *params =@{
//                                @"wd":@"help",
//                                };
//        NSMutableArray *arr =[NSMutableArray new];
//        [params enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
//            NSString *str =[NSString stringWithFormat:@"%@=%@",key,obj];
//            [arr addObject:str];
//            
//            
//        }];
//        NSString *res =[arr componentsJoinedByString:@"&"];
//        res =[res stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
//        res =[NSString stringWithFormat:@"%@?%@",Da,res];
//        NSLog(@"%@",res);
        
        NSURL *url =[NSURL URLWithString:Da1];
        NSURLRequest *req =[NSURLRequest requestWithURL:url];
        NSError *err;
        NSHTTPURLResponse *response;
        NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err];
        if (err) {
            NSLog(@"%@",err);
        }
        NSString *str =[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"size:%lu", data.length);
        NSLog(@"啊啊啊啊:%@",str);
    }
    return 0;
}
